package cn.getech.data.metadata.service.impl;


import cn.getech.data.metadata.entity.meta.CollectionTableFieldLog;
import cn.getech.data.metadata.mapper.CollectionTableFieldLogMapper;
import cn.getech.data.metadata.service.CollectionTableFieldLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service
public class CollectionTableFieldLogServiceImpl extends ServiceImpl<CollectionTableFieldLogMapper, CollectionTableFieldLog> implements CollectionTableFieldLogService {

    @Override
    public void saveTableFieldLog(List<CollectionTableFieldLog> tableLogList) {
        if (tableLogList.size() > 0) {
            int start = 0, limit = 200;
            List<CollectionTableFieldLog> collect = tableLogList.stream().skip(start).limit(limit).collect(Collectors.toList());
            while (collect != null && collect.size() > 0) {
                saveBatch(collect);

                start += limit;
                collect = tableLogList.stream().skip(start).limit(limit).collect(Collectors.toList());
            }
        }
    }
}
